using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Specialized;

namespace Be.Timvw.Framework.Web
{
    [TestClass]
    public class WhenBuildingParameterStringWithUriHelper
    {
        [TestMethod]
        public void ShouldReturnEmptyStringWhenParametersAreEmpty()
        {
            NameValueCollection parameters = new NameValueCollection();
            string actual = UriHelper.BuildParameterString(parameters);

            Assert.AreEqual(string.Empty, actual);
        }

        [TestMethod]
        public void ShouldReturnEmptyStringWhenParametersAreNull()
        {
            string actual = UriHelper.BuildParameterString(null);
            Assert.AreEqual(string.Empty, actual);
        }

        [TestMethod]
        public void ShouldReturnKeyEqualsValue()
        {
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("Key", "Value");
            string actual = UriHelper.BuildParameterString(parameters);

            Assert.AreEqual("Key=Value", actual);
        }

        [TestMethod]
        public void ShouldReturnKeyEqualsAndKeyEqualsOtherValue()
        {
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("Key", "Value");
            parameters.Add("Key", "OtherValue");
            string actual = UriHelper.BuildParameterString(parameters);

            Assert.AreEqual("Key=Value&Key=OtherValue", actual);
        }
    }
}
